using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO;
using System.Text.RegularExpressions;
using System.Configuration.Assemblies;

namespace BlueMoonsInc
{

    class PersonalAssistant
    {
        string fname, lname, mname, address, pn, email, country, state, dob, sex;
        string dom, time;
        string location, subject, notes;
        string menu;

        public PersonalAssistant()
        {
            Console.Title = "Personal Assistant";
            Console.WindowHeight = 30;
            Console.WindowWidth = 100;
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Clear();
        }

        public void Welcome()
        {
            Console.SetCursorPosition(40, 0);
            Console.WriteLine("WELCOME TO PERSONAL ASSISTANT");
            Console.SetCursorPosition(42, 1);
            Console.WriteLine("PRESS ENTER TO PROCEED");
            Console.ReadLine();
            FileStream FS = new FileStream("PersonalAssistant/RecentMeetingDate.txt", FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader SR = new StreamReader(FS);
            SR.BaseStream.Seek(0, SeekOrigin.Begin);
            string rd = SR.ReadLine();
            if (rd == null)
            {
            }
            if (Convert.ToDateTime(rd) == DateTime.Now.Date)
            {
                FileStream D = new FileStream("PersonalAssistant/RecentMeetingDetails.txt", FileMode.Open, FileAccess.Read);
                StreamReader DR = new StreamReader(D);
                DR.BaseStream.Seek(0, SeekOrigin.Begin);

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("ALERT! ALERT!! ALERT!!!");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\nYour Have an Appointment today (" + rd + ") which has the following info");
                
                string data = DR.ReadLine();
                while (data != null)
                {
                    Console.WriteLine(data);
                    data = DR.ReadLine();
                }
                D.Close();
                DR.Close();
            }

            FS.Close();
            SR.Close();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;

            PAMenu();
        }

        public void PAMenu()
        {
            Console.Title = "Personal Assistant | Main Menu";
            Console.WriteLine("PERSONAL ASSISTANT MENU");
            Console.WriteLine("\nA - Contact Details");
            Console.WriteLine("B - Meetings / Appointments");
            Console.WriteLine("C - About Personal Assistant");
            Console.WriteLine("D - Exit");
            menu = Console.ReadLine();
            menu = menu.ToUpper();

            while ((menu != "A") && (menu != "B") && (menu != "C") && (menu != "D"))
            {
                Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT A, B , C or D");
                menu = Console.ReadLine();
                menu = menu.ToUpper();
            }

            while ((menu == "A") || (menu == "B") || (menu == "C"))
            {
                switch (menu)
                {
                    case "A": Contacts(); break;
                    case "B": Meetings(); break;
                    case "C": About(); break;
                }
            }
        }

        public void Contacts()
        {
            Console.Title = "Personal Assistant | Contacts Menu";
            Console.WriteLine("\nPERSONAL ASSISTANT CONTACT MENU");
            Console.WriteLine("\nA - ADD NEW RECORD");
            Console.WriteLine("B - DELETE RECORD");
            Console.WriteLine("C - EDIT RECORD");
            Console.WriteLine("D - SEARCH RECORD");
            Console.WriteLine("E - BACK TO P.A MENU");
            string cact = Console.ReadLine();
            cact = cact.ToUpper();

            while ((cact != "A") && (cact != "B") && (cact != "C") && (cact != "D") && (cact != "E"))
            {
                Console.WriteLine("INVALID SELECTION \nPLEASE SELECT EITHER A, B, C, D or E");
                cact = Console.ReadLine();
                cact = cact.ToUpper();
            }

            switch (cact)
            {
                case "A": AddContact(); break;
                case "B": DeleteContact(); break;
                case "C": EditContact(); break;
                case "D": SearchContact(); break;
                case "E": Console.WriteLine(); PAMenu(); menu = ""; break;
            }
        }

        public void AddContact()
        {
            Console.Title = "Personal Assistant | Contact | Add Contact";
            sexException SE = new sexException();
            nullException NE = new nullException();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 40;
            Console.WriteLine("STORE CONTACT DETAILS");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write("\nNOTE: Fields with ");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(" are Compulsory");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" First Name : ");
            fname = Console.ReadLine();
            while (fname == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    fname = Console.ReadLine();
                }
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("\n*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Last Name : ");
            lname = Console.ReadLine();
            while (lname == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    lname = Console.ReadLine();
                }
            }
            Console.Write("\n  Middle Name : ");
            mname = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("\n*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Address : ");
            address = Console.ReadLine();
            while (address == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    address = Console.ReadLine();
                }
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("\n*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Gender : ");
            sex = Console.ReadLine();
            while (sex == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    sex = Console.ReadLine();
                }
            }
            while ((sex.ToUpper() != "MALE") && (sex.ToUpper() != "FEMALE") && (sex.ToUpper() != "ARMAPHRODITE"))
            {
                try
                {
                    throw SE;
                }
                catch (sexException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    sex = Console.ReadLine();
                }
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("\n*");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Date of Birth (YYYY-MM-DD) : ");
            dob = Console.ReadLine();
            string regexString = @"\d{4}-\d{2}-\d{2}";
            Match matches = Regex.Match(dob, regexString);
            while (matches.Success == false)
            {
                Console.WriteLine("\nENTER DATE IN FORMAT (Year-Month-Day)");
                dob = Console.ReadLine();
                regexString = @"\d{4}-\d{2}-\d{2}";
                matches = Regex.Match(dob, regexString);
                if (matches.Success == true)
                {
                }
            }
            try
            {
                while (Convert.ToDateTime(dob) > DateTime.Now)
                {
                    dobException DE = new dobException();
                    try
                    {
                        throw DE;
                    }
                    catch (dobException e)
                    {
                        Console.WriteLine("\n{0}", e.Message);
                        dob = Console.ReadLine();
                    }
                }
            }
            catch
            {
                Console.WriteLine("\nINVALID DATE FORMAT");
                dob = Console.ReadLine();
            }
            Console.Write("\n  Country : ");
            country = Console.ReadLine();
            Console.Write("\n  State of Origin : ");
            state = Console.ReadLine();
            Console.Write("\n  Phone Number : ");
            pn = Console.ReadLine();
            string regex = @"\d";
            Match match = Regex.Match(pn, regex);
            while (!match.Success)
            {
                if (pn == "")
                {
                    regex = @"";
                    match = Regex.Match(pn, regex);
                    pn = "";
                }
                else
                {
                    Console.WriteLine("\nPHONE NUMBER CAN ONLY CONTAIN NUMERIC DATA");
                    pn = Console.ReadLine();
                    regex = @"\d";
                    match = Regex.Match(pn, regex);
                    if (match.Success)
                    {
                    }
                }
            }
            Console.Write("\n  Email Address : ");
            email = Console.ReadLine();

            Console.Write("\nPreviewing Contact in " + " ");
            int timer = 7;
            while (timer >= 0)
            {
                Console.CursorLeft = 22;
                Console.Write(timer);
                Console.Beep();
                timer--;
                Thread.Sleep(800);
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("\nFirst Name : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + fname);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Last Name : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + lname);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Middle Name : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + mname);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Address : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + address);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Gender : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(sex);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Date of Birth : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + dob);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Country : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + country);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("State of Origin : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + state);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Phone Number : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + pn);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Email Address : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + email);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n\nA = Save Contact \nB = Cancel and Return to Contact Menu");
            string ans = Console.ReadLine();
            ans = ans.ToUpper();

            while ((ans != "A") && (ans != "B"))
            {
                Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT EITHER A or B");
                ans = Console.ReadLine();
                ans = ans.ToUpper();
            }

            if (ans == "A")
            {
                Console.WriteLine("\nPLEASE ENTER NAME TO USE TO STORE CONTACT : ");
                string cname = Console.ReadLine();

                while (Directory.Exists("PersonalAssistant/Contacts/" + cname))
                {
                    Console.WriteLine("\nTHE SPECIFIED NAME ALREADY EXISTS \nPLEASE SELECT ANOTHER NAME");
                    cname = Console.ReadLine();
                }

                DirectoryInfo DR = new DirectoryInfo(@"PersonalAssistant\Contacts");
                DR.CreateSubdirectory(cname);

                FileStream FN = new FileStream("PersonalAssistant/Contacts/" + cname + "/FirstName.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter FW = new StreamWriter(FN);
                FW.WriteLine(fname);
                FW.Flush();
                FW.Close();
                FN.Close();

                FileStream LN = new FileStream("PersonalAssistant/Contacts/" + cname + "/LastName.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter LW = new StreamWriter(LN);
                LW.WriteLine(lname);
                LW.Flush();
                LW.Close();
                LN.Close();

                FileStream MN = new FileStream("PersonalAssistant/Contacts/" + cname + "/MiddleName.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter MW = new StreamWriter(MN);
                MW.WriteLine(mname);
                MW.Flush();
                MW.Close();
                MN.Close();

                FileStream A = new FileStream("PersonalAssistant/Contacts/" + cname + "/Address.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter AW = new StreamWriter(A);
                AW.WriteLine(address);
                AW.Flush();
                AW.Close();
                A.Close();

                FileStream G = new FileStream("PersonalAssistant/Contacts/" + cname + "/Gender.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter GW = new StreamWriter(G);
                GW.WriteLine(sex);
                GW.Flush();
                GW.Close();
                G.Close();

                FileStream DB = new FileStream("PersonalAssistant/Contacts/" + cname + "/DateofBirth.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter DW = new StreamWriter(DB);
                DW.WriteLine(dob);
                DW.Flush();
                DW.Close();
                DB.Close();

                FileStream C = new FileStream("PersonalAssistant/Contacts/" + cname + "/Country.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter CW = new StreamWriter(C);
                CW.WriteLine(country);
                CW.Flush();
                CW.Close();
                C.Close();

                FileStream SR = new FileStream("PersonalAssistant/Contacts/" + cname + "/StateofOrigin.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter SW = new StreamWriter(SR);
                SW.WriteLine(state);
                SW.Flush();
                SW.Close();
                SR.Close();

                FileStream PN = new FileStream("PersonalAssistant/Contacts/" + cname + "/PhoneNumber.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter PW = new StreamWriter(PN);
                PW.WriteLine(pn);
                PW.Flush();
                PW.Close();
                PN.Close();

                FileStream EA = new FileStream("PersonalAssistant/Contacts/" + cname + "/EmailAddress.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter EW = new StreamWriter(EA);
                EW.WriteLine(email);
                EW.Flush();
                EW.Close();
                EA.Close();

                Console.WriteLine("\nCONTACT SAVED SUCCESFULLY");

                int time = 4;
                Console.Write("\nReturning to Contact Menu in " + " ");
                while (time >= 0)
                {
                    Console.CursorLeft = 40;
                    Console.Write(time);
                    Console.Beep();
                    time--;
                    Thread.Sleep(800);
                }
                Console.WriteLine();
                Contacts();

            }

            else if (ans == "B")
            {
                int time1 = 4;
                Console.Write("\nReturning to Contact Menu in " + " ");
                while (time1 >= 0)
                {
                    Console.CursorLeft = 40;
                    Console.Write(time1);
                    Console.Beep();
                    time1--;
                    Thread.Sleep(800);
                }
                Console.WriteLine();
                Contacts();
            }
        }

        public void DeleteContact()
        {
            Console.Title = "Personal Assistant | Contact | Delete Contact";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 40;
            Console.WriteLine("DELETE CONTACT");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO STORE CONTACT : ");
            string cname = Console.ReadLine();
            DeleteContactCheck(cname);
        }

        public void DeleteContactCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Contacts/" + name ) && name != "")
            {
                Console.WriteLine("\nDO YOU WANT TO DELETE CONTACT '" + name + "' WITH THE FOLLOWING INFORMATION? Y / N");

                FileStream FN = new FileStream("PersonalAssistant/Contacts/" + name + "/FirstName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader FW = new StreamReader(FN);
                FW.BaseStream.Seek(0, SeekOrigin.Begin);
                string f = FW.ReadLine();
                FW.Close();
                FN.Close();

                FileStream LN = new FileStream("PersonalAssistant/Contacts/" + name + "/LastName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader LW = new StreamReader(LN);
                LW.BaseStream.Seek(0, SeekOrigin.Begin);
                string l = LW.ReadLine();
                LW.Close();
                LN.Close();

                FileStream MN = new FileStream("PersonalAssistant/Contacts/" + name + "/MiddleName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader MW = new StreamReader(MN);
                MW.BaseStream.Seek(0, SeekOrigin.Begin);
                string m = MW.ReadLine();
                MW.Close();
                MN.Close();

                FileStream A = new FileStream("PersonalAssistant/Contacts/" + name + "/Address.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader AW = new StreamReader(A);
                AW.BaseStream.Seek(0, SeekOrigin.Begin);
                string a = AW.ReadLine();
                AW.Close();
                A.Close();

                FileStream G = new FileStream("PersonalAssistant/Contacts/" + name + "/Gender.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader GW = new StreamReader(G);
                GW.BaseStream.Seek(0, SeekOrigin.Begin);
                string sex = GW.ReadLine();
                GW.Close();
                G.Close();

                FileStream DB = new FileStream("PersonalAssistant/Contacts/" + name + "/DateofBirth.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader DW = new StreamReader(DB);
                DW.BaseStream.Seek(0, SeekOrigin.Begin);
                string dob = DW.ReadLine();
                DW.Close();
                DB.Close();

                FileStream C = new FileStream("PersonalAssistant/Contacts/" + name + "/Country.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader CW = new StreamReader(C);
                CW.BaseStream.Seek(0, SeekOrigin.Begin);
                string c = CW.ReadLine();
                CW.Close();
                C.Close();

                FileStream SR = new FileStream("PersonalAssistant/Contacts/" + name + "/StateofOrigin.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader SW = new StreamReader(SR);
                SW.BaseStream.Seek(0, SeekOrigin.Begin);
                string state = SW.ReadLine();
                SW.Close();
                SR.Close();

                FileStream PN = new FileStream("PersonalAssistant/Contacts/" + name + "/PhoneNumber.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader PW = new StreamReader(PN);
                PW.BaseStream.Seek(0, SeekOrigin.Begin);
                string pn = PW.ReadLine();
                PW.Close();
                PN.Close();

                FileStream EA = new FileStream("PersonalAssistant/Contacts/" + name + "/EmailAddress.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader EW = new StreamReader(EA);
                EW.BaseStream.Seek(0, SeekOrigin.Begin);
                string ea = EW.ReadLine();
                EW.Close();
                EA.Close();

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("\nFirst Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + f);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Last Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + l);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Middle Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + m);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Address : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + a);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Gender : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + sex);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Date of birth : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + dob);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Country : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + c);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("State of Origin : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + state);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Phone Number : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + pn);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Email Address : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + ea);
                Console.ForegroundColor = ConsoleColor.Gray;

                Console.ForegroundColor = ConsoleColor.Yellow;

                string ans = Console.ReadLine();
                ans = ans.ToUpper();

                while ((ans != "Y") && (ans != "N"))
                {
                    Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT EITHER (Y - Yes or N - No)");
                    ans = Console.ReadLine();
                    ans = ans.ToUpper();
                }

                if (ans == "Y")
                {
                    Console.Write("\nDeleting Contact in " + " ");
                    int time = 5;
                    while (time >= 0)
                    {
                        Console.CursorLeft = 26;
                        Console.Write(time);
                        Console.Beep();
                        time--;
                        Thread.Sleep(800);
                    }

                    File.Delete("PersonalAssistant/Contacts/" + name + "/FirstName.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/LastName.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/MiddleName.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/Address.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/Country.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/DateofBirth.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/Gender.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/PhoneNumber.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/StateofOrigin.txt");
                    File.Delete("PersonalAssistant/Contacts/" + name + "/EmailAddress.txt");

                    Directory.Delete(@"PersonalAssistant\Contacts\" + name);

                    Console.WriteLine("\n\nCONTACT DELETED SUCCESULLY");
                    Thread.Sleep(3000);
                    Contacts();
                }
                else
                {
                    Console.Write("\nReturning to Contact Details in " + " ");
                    int time = 5;
                    while (time >= 0)
                    {
                        Console.CursorLeft = 32;
                        Console.Write(time);
                        Console.Beep();
                        time--;
                        Thread.Sleep(800);
                    }
                }
            }

            else
            {
                Console.WriteLine("\nCONTACT WITH NAME DOESN'T EXIST");
                Thread.Sleep(2000);
                DeleteContact();
            }
        }

        public void EditContact()
        {
            Console.Title = "Personal Assistant | Contact | Edit Contact";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 32;
            Console.WriteLine("EDIT CONTACT");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO SAVE CONTACT : ");
            string cname = Console.ReadLine();

            EditContactCheck(cname);
        }

        public void EditContactCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Contacts/" + name ) && name != "")
            {
                Console.WriteLine("\nINFORMATION IN CONTACT '" + name + "'");

                FileStream FN = new FileStream("PersonalAssistant/Contacts/" + name + "/FirstName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader FW = new StreamReader(FN);
                FW.BaseStream.Seek(0, SeekOrigin.Begin);
                string f = FW.ReadLine();
                FW.Close();
                FN.Close();

                FileStream LN = new FileStream("PersonalAssistant/Contacts/" + name + "/LastName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader LW = new StreamReader(LN);
                LW.BaseStream.Seek(0, SeekOrigin.Begin);
                string l = LW.ReadLine();
                LW.Close();
                LN.Close();

                FileStream MN = new FileStream("PersonalAssistant/Contacts/" + name + "/MiddleName.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader MW = new StreamReader(MN);
                MW.BaseStream.Seek(0, SeekOrigin.Begin);
                string m = MW.ReadLine();
                MW.Close();
                MN.Close();

                FileStream A = new FileStream("PersonalAssistant/Contacts/" + name + "/Address.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader AW = new StreamReader(A);
                AW.BaseStream.Seek(0, SeekOrigin.Begin);
                string a = AW.ReadLine();
                AW.Close();
                A.Close();

                FileStream G = new FileStream("PersonalAssistant/Contacts/" + name + "/Gender.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader GW = new StreamReader(G);
                GW.BaseStream.Seek(0, SeekOrigin.Begin);
                string sex = GW.ReadLine();
                GW.Close();
                G.Close();

                FileStream DB = new FileStream("PersonalAssistant/Contacts/" + name + "/DateofBirth.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader DW = new StreamReader(DB);
                DW.BaseStream.Seek(0, SeekOrigin.Begin);
                string dob = DW.ReadLine();
                DW.Close();
                DB.Close();

                FileStream C = new FileStream("PersonalAssistant/Contacts/" + name + "/Country.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader CW = new StreamReader(C);
                CW.BaseStream.Seek(0, SeekOrigin.Begin);
                string c = CW.ReadLine();
                CW.Close();
                C.Close();

                FileStream SR = new FileStream("PersonalAssistant/Contacts/" + name + "/StateofOrigin.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader SW = new StreamReader(SR);
                SW.BaseStream.Seek(0, SeekOrigin.Begin);
                string state = SW.ReadLine();
                SW.Close();
                SR.Close();

                FileStream PN = new FileStream("PersonalAssistant/Contacts/" + name + "/PhoneNumber.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader PW = new StreamReader(PN);
                PW.BaseStream.Seek(0, SeekOrigin.Begin);
                string pn = PW.ReadLine();
                PW.Close();
                PN.Close();

                FileStream EA = new FileStream("PersonalAssistant/Contacts/" + name + "/EmailAddress.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader EW = new StreamReader(EA);
                EW.BaseStream.Seek(0, SeekOrigin.Begin);
                string ea = EW.ReadLine();
                EW.Close();
                EA.Close();

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("\nFirst Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + f);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Last Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + l);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Middle Name : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + m);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Address : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + a);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Gender : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + sex);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Date of birth : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + dob);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Country : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + c);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("State of Origin : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + state);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Phone Number : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + pn);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Email Address : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + ea);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.ForegroundColor = ConsoleColor.Yellow;

                Console.WriteLine("\nEDIT CONTACT '" + name + "'");
                Console.WriteLine("Press Enter to Skip fields you don't want to Edit");
                Console.WriteLine("\nFIRST NAME");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + f + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nf = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nLAST NAME");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + l + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nl = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nMIDDLE NAME");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + m + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nm = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nADDRESS");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + a + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string na = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nGENDER");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + sex + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nsex = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                while ((nsex.ToUpper() != "MALE") && (nsex.ToUpper() != "FEMALE") && (nsex.ToUpper() != "ARMAPHRODITE") && (nsex.ToUpper() != ""))
                {
                    try
                    {
                        sexException SE = new sexException();
                        throw SE;
                    }
                    catch (sexException e)
                    {
                        Console.WriteLine("\n{0}", e.Message);
                        nsex = Console.ReadLine();
                    }
                }
                Console.WriteLine("\nDATE OF BIRTH");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + dob + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string ndob = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nCOUNTRY");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + c + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nc = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nSTATE OF ORIGIN");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + state + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nstate = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nPHONE NUMBER");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + pn + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string npn = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nEMAIL ADDRESS");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("From (" + ea + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nea = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;

                if (nf != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/FirstName.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nf);
                    D.Flush();
                    D.Close();
                    ND.Close();

                }

                if (nl != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/LastName.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nl);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nm != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/MiddleName.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nm);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (na != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/Address.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(na);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nsex != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/Gender.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nsex);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (ndob != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/DateofBirth.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(ndob);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nc != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/Country.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nc);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nstate != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/StateofOrigin.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nstate);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (npn != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/PhoneNumber.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(npn);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nea != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Contacts/" + name + "/EmailAddress.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nea);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                Console.WriteLine();

                if (nf != "")
                {
                    Console.Write("FIRST NAME , ");
                }

                if (nl != "")
                {
                    Console.Write("LAST NAME , ");
                }

                if (nm != "")
                {
                    Console.Write("MIDDLE NAME , ");
                }

                if (na != "")
                {
                    Console.Write("ADDRESS , ");
                }

                if (nsex != "")
                {
                    Console.Write("GENDER , ");
                }

                if (ndob != "")
                {
                    Console.Write("DATE OF BIRTH , ");
                }

                if (nc != "")
                {
                    Console.Write("COUNTRY , ");
                }

                if (nstate != "")
                {
                    Console.Write("STATE OF ORIGIN , ");
                }

                if (npn != "")
                {
                    Console.Write("PHONE NUMBER , ");
                }

                if (nea != "")
                {
                    Console.Write("EMAIL ADDRESS , ");
                }

                if (nf != "" || nl != "" || nm != "" || na != "" || nsex != "" || ndob != "" || nc != "" || nstate != "" || npn != "" || nea != "")
                {
                    Console.Write(" WERE EDITED SUCCESSFULLY");
                }

                if ((nf == "") && (nl == "") && (nm == "") && (na == "") && (nsex == "") && (ndob == "") && (nc == "") && (nstate == "") && (npn == "") && (nea == ""))
                {
                    Console.Write("NO FIELDS WERE CHANGED");
                    Thread.Sleep(2000);
                    Console.WriteLine();
                    Contacts();
                }

                Thread.Sleep(2000);
                Console.WriteLine();
                Contacts();
            }
            else
            {
                Console.WriteLine("\nCONTACT WITH NAME DOESN'T EXIST");
                Thread.Sleep(2000);
                EditContact();
            }
        }

        public void SearchContact()
        {
            Console.Title = "Personal Assistant | Contact | Search Contact";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 40;
            Console.WriteLine("SEARCH CONTACT");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO STORE CONTACT : ");
            string cname = Console.ReadLine();
            SearchContactCheck(cname);
        }

        public void SearchContactCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Contacts/" + name ) && name != "")
            {
                Console.WriteLine("\nCONTACT FOUND \nWHAT DO YOU WANT TO DO?");
                Console.WriteLine("\nA - Edit Contact \nB - Delete Contact \nC - View Contact");
                string act = Console.ReadLine();
                act = act.ToUpper();

                while ((act != "A") && (act != "B") && (act != "C"))
                {
                    Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT A, B or C");
                    act = Console.ReadLine();
                    act = act.ToUpper();
                }

                if (act == "A")
                {
                    EditContactCheck(name);
                }
                else if (act == "B")
                {
                    DeleteContactCheck(name);
                }
                else if (act == "C")
                {
                    Console.WriteLine("\nINFORMATION IN CONTACT");
                    FileStream FN = new FileStream("PersonalAssistant/Contacts/" + name + "/FirstName.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader FW = new StreamReader(FN);
                    FW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string f = FW.ReadLine();
                    FW.Close();
                    FN.Close();

                    FileStream LN = new FileStream("PersonalAssistant/Contacts/" + name + "/LastName.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader LW = new StreamReader(LN);
                    LW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string l = LW.ReadLine();
                    LW.Close();
                    LN.Close();

                    FileStream MN = new FileStream("PersonalAssistant/Contacts/" + name + "/MiddleName.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader MW = new StreamReader(MN);
                    MW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string m = MW.ReadLine();
                    MW.Close();
                    MN.Close();

                    FileStream A = new FileStream("PersonalAssistant/Contacts/" + name + "/Address.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader AW = new StreamReader(A);
                    AW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string a = AW.ReadLine();
                    AW.Close();
                    A.Close();

                    FileStream G = new FileStream("PersonalAssistant/Contacts/" + name + "/Gender.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader GW = new StreamReader(G);
                    GW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string sex = GW.ReadLine();
                    GW.Close();
                    G.Close();

                    FileStream DB = new FileStream("PersonalAssistant/Contacts/" + name + "/DateofBirth.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader DW = new StreamReader(DB);
                    DW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string dob = DW.ReadLine();
                    DW.Close();
                    DB.Close();

                    FileStream C = new FileStream("PersonalAssistant/Contacts/" + name + "/Country.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader CW = new StreamReader(C);
                    CW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string c = CW.ReadLine();
                    CW.Close();
                    C.Close();

                    FileStream SR = new FileStream("PersonalAssistant/Contacts/" + name + "/StateofOrigin.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader SW = new StreamReader(SR);
                    SW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string state = SW.ReadLine();
                    SW.Close();
                    SR.Close();

                    FileStream PN = new FileStream("PersonalAssistant/Contacts/" + name + "/PhoneNumber.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader PW = new StreamReader(PN);
                    PW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string pn = PW.ReadLine();
                    PW.Close();
                    PN.Close();

                    FileStream EA = new FileStream("PersonalAssistant/Contacts/" + name + "/EmailAddress.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader EW = new StreamReader(EA);
                    EW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string ea = EW.ReadLine();
                    EW.Close();
                    EA.Close();

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("\nFirst Name : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + f);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Last Name : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + l);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Middle Name : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + m);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Address : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + a);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Gender : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + sex);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Date of birth : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + dob);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Country : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + c);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("State of Origin : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + state);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Phone Number : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + pn);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Email Address : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + ea);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Yellow;

                    Console.WriteLine("\nPRESS ENTER TO RETURN TO CONTACT DETAILS");
                    Console.ReadLine();
                    Contacts();
                }

            }
            else
            {
                Console.WriteLine("\nCONTACT WITH NAME DOESN'T EXIST");
                Thread.Sleep(2000);
                SearchContact();
            }
        }

        public void Meetings()
        {
            Console.Title = "Personal Assistant | Meetings";
            Console.WriteLine("\nPERSONAL ASSISTANT MEETINGS / APPOINMENTS MENU");
            Console.WriteLine("\nA - ADD NEW RECORD");
            Console.WriteLine("B - DELETE RECORD");
            Console.WriteLine("C - EDIT RECORD");
            Console.WriteLine("D - SEARCH RECORD");
            Console.WriteLine("E - BACK TO P.A MENU");
            string cact = Console.ReadLine();
            cact = cact.ToUpper();

            while ((cact != "A") && (cact != "B") && (cact != "C") && (cact != "D") && (cact != "E"))
            {
                Console.WriteLine("INVALID SELECTION \nPLEASE SELECT EITHER A, B, C, D or E");
                cact = Console.ReadLine();
                cact = cact.ToUpper();
            }

            switch (cact)
            {
                case "A": AddMeeting(); break;
                case "B": DeleteMeeting(); break;
                case "C": EditMeeting(); break;
                case "D": SearchMeeting(); break;
                case "E": Console.WriteLine(); PAMenu(); menu = ""; break;
            }
        }

        public void AddMeeting()
        {
            Console.Title = "Personal Assistant | Meetings | Add Meeting";
            FileStream RC = new FileStream("PersonalAssistant/RecentMeetingDate.txt", FileMode.Open, FileAccess.ReadWrite);
            StreamReader RR = new StreamReader(RC);
            StreamWriter RW = new StreamWriter(RC);
            RR.BaseStream.Seek(0, SeekOrigin.Begin);
            string recent = RR.ReadLine();
            nullException NE = new nullException();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 25;
            Console.WriteLine("STORE MEETING / APPOINTMENT DETAILS");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nALL FIELDS ARE COMPULSORY EXCEPT (NOTES)");
            Console.Write("\nSubject : ");
            subject = Console.ReadLine();
            while (subject == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    subject = Console.ReadLine();
                }
            }
            Console.Write("\nLocation : ");
            location = Console.ReadLine();
            while (location == "")
            {
                try
                {
                    throw NE;
                }
                catch (nullException e)
                {
                    Console.WriteLine("\n{0}", e.Message);
                    location = Console.ReadLine();
                }
            }
            Console.Write("\nDate of Meeting (YYYY-MM-DD) : ");
            dom = Console.ReadLine();
            string regexString = @"\d{4}-\d{2}-\d{2}";
            Match matches = Regex.Match(dom, regexString);
            while (!matches.Success)
            {
                Console.WriteLine("\nENTER DATE IN FORMAT (Year-Month-Day)");
                dom = Console.ReadLine();
                regexString = @"\d{4}-\d{2}-\d{2}";
                matches = Regex.Match(dom, regexString);
                if (matches.Success)
                {
                }
            }
            try
            {
                while (Convert.ToDateTime(dom).Day < DateTime.Now.Day)
                {
                    domException DE = new domException();
                    try
                    {
                        throw DE;
                    }
                    catch (domException e)
                    {
                        Console.WriteLine("\n{0}", e.Message);
                        dom = Console.ReadLine();
                        regexString = @"\d{4}-\d{2}-\d{2}";
                        matches = Regex.Match(dom, regexString);
                        if (matches.Success)
                        {
                        }
                        while (!matches.Success)
                        {
                            Console.WriteLine("\nENTER DATE IN FORMAT (Year-Month-Day)");
                            dom = Console.ReadLine();
                            regexString = @"\d{4}-\d{2}-\d{2}";
                            matches = Regex.Match(dom, regexString);
                            if (matches.Success)
                            {
                            }
                        }
                    }
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("\nINVALID DATE FORMAT");
                Thread.Sleep(2000);
                Console.WriteLine();
                Meetings();
            }
            Console.Write("\nTime of Meeting (HH:MM) : ");
            time = Console.ReadLine();

            string regexStringT = @"\d{1}|\d{2}:\d{2}";
            Match matchesT = Regex.Match(time, regexStringT);

            while (!matchesT.Success)
            {
                Console.WriteLine("\nENTER TIME IN 24hr FORMAT (Hour:Minute)");
                time = Console.ReadLine();
                regexStringT = @"\d{1}|\d{2}:\d{2}";
                matchesT = Regex.Match(time, regexStringT);
                if (matchesT.Success)
                {
                }
            }

            Console.Write("\nNotes : ");
            notes = Console.ReadLine();

            Console.Write("\nPreviewing Appointment in " + " ");
            int timer = 7;
            while (timer >= 0)
            {
                Console.CursorLeft = 30;
                Console.Write(timer);
                Console.Beep();
                timer--;
                Thread.Sleep(800);
            }
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("\nSubject : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + subject);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Location : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + location);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Date of Meeting : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + dom);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Time of Meeting : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(" " + time);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Notes : ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(notes);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n\nA = Save Appointment \nB = Cancel and Return to Meetings Menu");
            string ans = Console.ReadLine();
            ans = ans.ToUpper();

            while ((ans != "A") && (ans != "B"))
            {
                Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT EITHER A or B");
                ans = Console.ReadLine();
                ans = ans.ToUpper();
            }

            if (ans == "A")
            {
                Console.WriteLine("\nPLEASE ENTER NAME TO USE TO STORE APPOINTMENT : ");
                string cname = Console.ReadLine();

                while (Directory.Exists("PersonalAssistant/Meetings/" + cname))
                {
                    Console.WriteLine("\nTHE SPECIFIED NAME ALREADY EXISTS \nPLEASE SELECT ANOTHER NAME");
                    cname = Console.ReadLine();
                }
                DirectoryInfo DR = new DirectoryInfo(@"PersonalAssistant\Meetings");
                DR.CreateSubdirectory(cname);

                FileStream S = new FileStream("PersonalAssistant/Meetings/" + cname + "/Subject.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter SW = new StreamWriter(S);
                SW.WriteLine(subject);
                SW.Flush();
                SW.Close();
                S.Close();

                FileStream L = new FileStream("PersonalAssistant/Meetings/" + cname + "/Location.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter LW = new StreamWriter(L);
                LW.WriteLine(location);
                LW.Flush();
                LW.Close();
                L.Close();

                FileStream DM = new FileStream("PersonalAssistant/Meetings/" + cname + "/DateofMeeting.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter DW = new StreamWriter(DM);
                DW.WriteLine(dom);
                DW.Flush();
                DW.Close();
                DM.Close();
                if (recent == null)
                {
                    FileStream FR = new FileStream("PersonalAssistant/RecentMeetingName.txt", FileMode.Create);
                    FR.Close();
                    RW.WriteLine(dom);
                    FileStream R = new FileStream("PersonalAssistant/RecentMeetingName.txt", FileMode.Truncate, FileAccess.ReadWrite);
                    StreamWriter WR = new StreamWriter(R);
                    WR.WriteLine(cname);
                    WR.Flush();
                    WR.Close();
                    R.Close();
                    FileStream DT = new FileStream("PersonalAssistant/RecentMeetingDetails.txt", FileMode.Create, FileAccess.Write);
                    StreamWriter DTR = new StreamWriter(DT);
                    DTR.WriteLine("Subject : " + subject);
                    DTR.WriteLine("Location : " + location);
                    DTR.WriteLine("Date : " + dom);
                    DTR.WriteLine("Time : " + time);
                    DTR.WriteLine("Notes : " + notes);
                    DTR.Flush();
                    DTR.Close();
                    DT.Close();
                    RW.Flush();
                    RW.Close();
                    RC.Close();
                }
                else if (Convert.ToDateTime(recent) > Convert.ToDateTime(dom))
                {
                    RW.Close();
                    RC.Close();
                    FileStream R = new FileStream("PersonalAssistant/RecentMeetingName.txt", FileMode.Truncate, FileAccess.ReadWrite);
                    StreamWriter WR = new StreamWriter(R);
                    WR.WriteLine(cname);
                    WR.Flush();
                    WR.Close();
                    R.Close();
                    FileStream RM = new FileStream("PersonalAssistant/RecentMeetingDate.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter RMW = new StreamWriter(RM);
                    RMW.WriteLine(dom);
                    RMW.Flush();
                    RMW.Close();
                    RM.Close();
                    FileStream DT = new FileStream("PersonalAssistant/RecentMeetingDetails.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter DTR = new StreamWriter(DT);
                    DTR.WriteLine("Subject : " + subject);
                    DTR.WriteLine("Location : " + location);
                    DTR.WriteLine("Date : " + dom);
                    DTR.WriteLine("Time : " + time);
                    DTR.WriteLine("Notes : " + notes);
                    DTR.Close();
                    DT.Close();
                }
                else
                {
                    RW.Close();
                    RC.Close();
                }
                FileStream TM = new FileStream("PersonalAssistant/Meetings/" + cname + "/TimeofMeeting.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter TW = new StreamWriter(TM);
                TW.WriteLine(time);
                TW.Flush();
                TW.Close();
                TM.Close();

                FileStream N = new FileStream("PersonalAssistant/Meetings/" + cname + "/Notes.txt", FileMode.CreateNew, FileAccess.ReadWrite);
                StreamWriter NW = new StreamWriter(N);
                NW.WriteLine(notes);
                NW.Flush();
                NW.Close();
                N.Close();

                Console.WriteLine("\nAPPOINTMENT SAVED SUCCESFULLY");

                int mtime = 4;
                Console.Write("\nReturning to Meetings Menu in " + " ");
                while (mtime >= 0)
                {
                    Console.CursorLeft = 35;
                    Console.Write(mtime);
                    Console.Beep();
                    mtime--;
                    Thread.Sleep(800);
                }
                Console.WriteLine();
                Meetings();
            }
            else
            {
                int mtime1 = 4;
                Console.Write("\nReturning to Meetings Menu in " + " ");
                while (mtime1 >= 0)
                {
                    Console.CursorLeft = 35;
                    Console.Write(mtime1);
                    Console.Beep();
                    mtime1--;
                    Thread.Sleep(800);
                }
                Console.WriteLine();
                Meetings();
            }
        }

        public void DeleteMeeting()
        {
            Console.Title = "Personal Assistant | Meetings | Delete Meeting";
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.CursorLeft = 25;
            Console.WriteLine("DELETE MEETING / APPOINTMENT");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO SAVE CONTACT : ");
            string cname = Console.ReadLine();

            DeleteMeetingCheck(cname);
        }

        public void DeleteMeetingCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Meetings/" + name) && name != "")
            {
                Console.WriteLine("\nDO YOU WANT TO DELETE APPOINTMENT '" + name + "' WITH THE FOLLOWING INFORMATION? Y / N");

                FileStream S = new FileStream("PersonalAssistant/Meetings/" + name + "/Subject.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader SW = new StreamReader(S);
                SW.BaseStream.Seek(0, SeekOrigin.Begin);
                string s = SW.ReadLine();
                SW.Close();
                S.Close();

                FileStream L = new FileStream("PersonalAssistant/Meetings/" + name + "/Location.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader LW = new StreamReader(L);
                LW.BaseStream.Seek(0, SeekOrigin.Begin);
                string l = LW.ReadLine();
                LW.Close();
                L.Close();

                FileStream DM = new FileStream("PersonalAssistant/Meetings/" + name + "/DateofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader DW = new StreamReader(DM);
                DW.BaseStream.Seek(0, SeekOrigin.Begin);
                string dom = DW.ReadLine();
                DW.Close();
                DM.Close();

                FileStream TM = new FileStream("PersonalAssistant/Meetings/" + name + "/TimeofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader TW = new StreamReader(TM);
                TW.BaseStream.Seek(0, SeekOrigin.Begin);
                string tom = TW.ReadLine();
                TW.Close();
                TM.Close();

                FileStream N = new FileStream("PersonalAssistant/Meetings/" + name + "/Notes.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader NW = new StreamReader(N);
                NW.BaseStream.Seek(0, SeekOrigin.Begin);
                string note = NW.ReadLine();
                NW.Close();
                N.Close();

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("\nSubject : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + s);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Location : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + l);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Date of Meeting : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + dom);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Time of Meeting : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + tom);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Notes : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + note);
                Console.ForegroundColor = ConsoleColor.Yellow;
                string ans = Console.ReadLine();
                ans = ans.ToUpper();

                while ((ans != "Y") && (ans != "N"))
                {
                    Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT Y - Yes or N - No");
                    ans = Console.ReadLine();
                    ans = ans.ToUpper();
                }

                if (ans == "Y")
                {
                    Console.Write("\nDeleting Appointment in " + " ");
                    int dmtime = 5;
                    while (dmtime >= 0)
                    {
                        Console.CursorLeft = 26;
                        Console.Write(dmtime);
                        Console.Beep();
                        dmtime--;
                        Thread.Sleep(800);
                    }

                    FileStream R = new FileStream("PersonalAssistant/RecentMeetingName.txt", FileMode.Open, FileAccess.Read);
                    StreamReader RR = new StreamReader(R);
                    RR.BaseStream.Seek(0, SeekOrigin.Begin);
                    string recentm = RR.ReadLine();
                    RR.Close();
                    R.Close();
                    if (recentm == name)
                    {
                        File.Delete("PersonalAssistant/RecentMeetingDate.txt");
                        File.Delete("PersonalAssistant/RecentMeetingName.txt");
                        File.Delete("PersonalAssistant/RecentMeetingDetails.txt");
                    }

                    File.Delete("PersonalAssistant/Meetings/" + name + "/Subject.txt");
                    File.Delete("PersonalAssistant/Meetings/" + name + "/Location.txt");
                    File.Delete("PersonalAssistant/Meetings/" + name + "/DateofMeeting.txt");
                    File.Delete("PersonalAssistant/Meetings/" + name + "/TimeofMeeting.txt");
                    File.Delete("PersonalAssistant/Meetings/" + name + "/Notes.txt");

                    Directory.Delete(@"PersonalAssistant/Meetings/" + name);

                    Console.WriteLine("\n\nAPPOINTMENT DELETED SUCCESSFULLY");
                    Thread.Sleep(2000);
                    Meetings();
                }
                else
                {
                    Console.Write("\nReturning to Meetings in " + " ");
                    int time = 5;
                    while (time >= 0)
                    {
                        Console.CursorLeft = 29;
                        Console.Write(time);
                        Console.Beep();
                        time--;
                        Thread.Sleep(800);
                    }
                }
            }
            else
            {
                Console.WriteLine("\nMEETING / APPOINTMENT WITH NAME DOESN'T EXIST");
                Thread.Sleep(2000);
                DeleteMeeting();
            }
        }

        public void EditMeeting()
        {
            Console.Title = "Personal Assistant | Meetings | Edit Meeting"; 
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.CursorLeft = 22;
            Console.WriteLine("EDIT MEETING / APPOINTMENT DETAILS");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO SAVE CONTACT : ");
            string cname = Console.ReadLine();

            EditMeetingCheck(cname);
        }

        public void EditMeetingCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Meetings/" + name) && name != "")
            {
                Console.WriteLine("\nINFORMATION IN APPOINTMENT '" + name + "'");

                FileStream S = new FileStream("PersonalAssistant/Meetings/" + name + "/Subject.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader SW = new StreamReader(S);
                SW.BaseStream.Seek(0, SeekOrigin.Begin);
                string s = SW.ReadLine();
                SW.Close();
                S.Close();

                FileStream L = new FileStream("PersonalAssistant/Meetings/" + name + "/Location.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader LW = new StreamReader(L);
                LW.BaseStream.Seek(0, SeekOrigin.Begin);
                string l = LW.ReadLine();
                LW.Close();
                L.Close();

                FileStream DM = new FileStream("PersonalAssistant/Meetings/" + name + "/DateofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader DW = new StreamReader(DM);
                DW.BaseStream.Seek(0, SeekOrigin.Begin);
                string dom = DW.ReadLine();
                DW.Close();
                DM.Close();

                FileStream TM = new FileStream("PersonalAssistant/Meetings/" + name + "/TimeofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader TW = new StreamReader(TM);
                TW.BaseStream.Seek(0, SeekOrigin.Begin);
                string tom = TW.ReadLine();
                TW.Close();
                TM.Close();

                FileStream N = new FileStream("PersonalAssistant/Meetings/" + name + "/Notes.txt", FileMode.Open, FileAccess.ReadWrite);
                StreamReader NW = new StreamReader(N);
                NW.BaseStream.Seek(0, SeekOrigin.Begin);
                string note = NW.ReadLine();
                NW.Close();
                N.Close();

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("\nSubject : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + s);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Location : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + l);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Date of Meeting : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + dom);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Time of Meeting : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + tom);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("Notes : ");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(" " + note);
                Console.ForegroundColor = ConsoleColor.Yellow;

                Console.WriteLine("\nEDIT APPOINTMENT '" + name + "'");
                Console.WriteLine("Press Enter to Skip fields you don't want to Edit");
                Console.WriteLine("\nSUBJECT");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("From (" + s + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string ns = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nLOCATION");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("From (" + l + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nl = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nDATE OF MEETING");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("From (" + dom + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string ndom = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;
                if (ndom == "")
                {
                }
                else
                {
                    string regexString = @"\d{4}-\d{2}-\d{2}";
                    Match matches = Regex.Match(ndom, regexString);
                    while (matches.Success == false)
                    {
                        Console.WriteLine("\nENTER DATE IN FORMAT (Year-Month-Day)");
                        ndom = Console.ReadLine();
                        regexString = @"\d{4}-\d{2}-\d{2}";
                        matches = Regex.Match(ndom, regexString);
                        if ((matches.Success == true) || (ndom == ""))
                        {
                        }
                    }
                    try
                    {
                        while (Convert.ToDateTime(ndom).Day < DateTime.Now.Day)
                        {
                            domException DE = new domException();
                            try
                            {
                                throw DE;
                            }
                            catch (domException e)
                            {
                                Console.WriteLine("\n{0}", e.Message);
                                ndom = Console.ReadLine();
                                regexString = @"\d{4}-\d{2}-\d{2}";
                                matches = Regex.Match(ndom, regexString);
                                if (matches.Success == true)
                                {
                                }
                                while (matches.Success == false)
                                {
                                    Console.WriteLine("\nENTER DATE IN FORMAT (Year-Month-Day)");
                                    ndom = Console.ReadLine();
                                    regexString = @"\d{4}-\d{2}-\d{2}";
                                    matches = Regex.Match(ndom, regexString);
                                    if (matches.Success == true)
                                    {
                                    }
                                }
                            }
                        }
                    }
                    catch (FormatException)
                    {
                        Console.WriteLine("\nINVALID DATE FORMAT");
                        Thread.Sleep(2000);
                        Console.WriteLine();
                        Meetings();
                    }
                }
                Console.WriteLine("\nTIME OF MEETING");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("From (" + tom + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string ntom = Console.ReadLine();
                if (ntom == "")
                {
                }
                else
                {
                    string regexStringT = @"\d{1}|\d{2}:\d{2}";
                    Match matchesT = Regex.Match(ntom, regexStringT);
                    while (matchesT.Success == false)
                    {
                        Console.WriteLine("\nENTER TIME IN 24hr FORMAT (Hour:Minute)");
                        ntom = Console.ReadLine();
                        regexStringT = @"\d{1}|\d{2}:\d{2}";
                        matchesT = Regex.Match(ntom, regexStringT);
                        if ((matchesT.Success == true) || (ntom == ""))
                        {
                        }
                    }
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\nNOTES");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("From (" + note + ") to ");
                Console.ForegroundColor = ConsoleColor.Green;
                string nnote = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.Yellow;

                if (ns != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Meetings/" + name + "/Subject.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(ns);
                    D.Flush();
                    D.Close();
                    ND.Close();

                }

                if (nl != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Meetings/" + name + "/Location.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nl);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (ndom != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Meetings/" + name + "/DateofMeeting.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(ndom);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (ntom != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Meetings/" + name + "/TimeofMeeting.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(ntom);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                if (nnote != "")
                {
                    FileStream ND = new FileStream("PersonalAssistant/Meetings/" + name + "/Notes.txt", FileMode.Truncate, FileAccess.Write);
                    StreamWriter D = new StreamWriter(ND);
                    D.WriteLine(nnote);
                    D.Flush();
                    D.Close();
                    ND.Close();
                }

                Console.WriteLine();

                if (ns != "")
                {
                    Console.Write("SUBJECT , ");
                }

                if (nl != "")
                {
                    Console.Write("LOCATION , ");
                }

                if (ndom != "")
                {
                    Console.Write("DATE OF MEETING , ");
                }

                if (ntom != "")
                {
                    Console.Write("TIME OF MEETING , ");
                }

                if (nnote != "")
                {
                    Console.Write("NOTES , ");
                }

                if (ns != "" || nl != "" || ndom != "" || ntom != "" || nnote != "")
                {
                    Console.Write(" WERE EDITED SUCCESSFULLY");
                }

                if ((ns == "") && (nl == "") && (ndom == "") && (ntom == "") && (nnote == ""))
                {
                    Console.Write("NO FIELDS WERE CHANGED");
                    Thread.Sleep(2000);
                    Console.WriteLine();
                    Meetings();
                }

                Thread.Sleep(2000);
                Console.WriteLine();
                Meetings();
            }
        }

        public void SearchMeeting()
        {
            Console.Title = "Personal Assistant | Meetings | Search Meeting";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();
            Console.CursorLeft = 40;
            Console.WriteLine("SEARCH MEETING / APPOINTMENT");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPLEASE ENTER NAME USED TO STORE APPOINTMENT : ");
            string cname = Console.ReadLine();
            SearchMeetingCheck(cname);
        }

        public void SearchMeetingCheck(string name)
        {
            if (Directory.Exists("PersonalAssistant/Meetings/" + name) && name != "")
            {
                Console.WriteLine("\nAPPOINTMENT FOUND \nWHAT DO YOU WANT TO DO?");
                Console.WriteLine("\nA - Edit Appointment \nB - Delete AppointMent \nC - View Appointment");
                string act = Console.ReadLine();
                act = act.ToUpper();

                while ((act != "A") && (act != "B") && (act != "C"))
                {
                    Console.WriteLine("\nINVALID SELECTION \nPLEASE SELECT A, B or C");
                    act = Console.ReadLine();
                    act = act.ToUpper();
                }

                if (act == "A")
                {
                    EditMeetingCheck(name);
                }
                else if (act == "B")
                {
                    DeleteMeetingCheck(name);
                }
                else if (act == "C")
                {
                    Console.WriteLine("\nINFORMATION IN APPOINTMENT '" + name + "'");

                    FileStream S = new FileStream("PersonalAssistant/Meetings/" + name + "/Subject.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader SW = new StreamReader(S);
                    SW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string s = SW.ReadLine();
                    SW.Close();
                    S.Close();

                    FileStream L = new FileStream("PersonalAssistant/Meetings/" + name + "/Location.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader LW = new StreamReader(L);
                    LW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string l = LW.ReadLine();
                    LW.Close();
                    L.Close();

                    FileStream DM = new FileStream("PersonalAssistant/Meetings/" + name + "/DateofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader DW = new StreamReader(DM);
                    DW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string dom = DW.ReadLine();
                    DW.Close();
                    DM.Close();

                    FileStream TM = new FileStream("PersonalAssistant/Meetings/" + name + "/TimeofMeeting.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader TW = new StreamReader(TM);
                    TW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string tom = TW.ReadLine();
                    TW.Close();
                    TM.Close();

                    FileStream N = new FileStream("PersonalAssistant/Meetings/" + name + "/Notes.txt", FileMode.Open, FileAccess.ReadWrite);
                    StreamReader NW = new StreamReader(N);
                    NW.BaseStream.Seek(0, SeekOrigin.Begin);
                    string note = NW.ReadLine();
                    NW.Close();
                    N.Close();

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("\nSubject : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + s);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Location : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + l);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Date of Meeting : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + dom);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Time of Meeting : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + tom);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("Notes : ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(" " + note);
                    Console.ForegroundColor = ConsoleColor.Yellow;

                    Console.WriteLine("\nPRESS ENTER TO RETURN TO MEETING / APPOINTMENTS");
                    Console.ReadLine();
                    Meetings();
                }
            }
            else
            {
                Console.WriteLine("\nAPPOINTMENT WITH NAME DOESN'T EXIST");
                Thread.Sleep(2000);
                SearchMeeting();
            }
        }

        public void About()
        {
            Console.WriteLine("\nABOUT PERSONAL ASSISTANT");
            Console.WriteLine("\nPersonal Assistant is an Application to Store and retrieve personal information. It enables you to store details of various people. It also enables you to store details of meetings and appointments. Personal Assistant displays reminders to you for meetings and appointments. The contact details and Meetings/Appointments details enables you to Add, Edit, Delete and Search Information.");
            Console.WriteLine("\nThank you for Choosing Personal Assistant");
            Console.WriteLine("Press ENTER to go back to P.A Menu");
            Console.ReadLine();
            PAMenu();
        }

        static void M_ain(string[] args)
        {
            if (!Directory.Exists("PersonalAssistant"))
            {
                Directory.CreateDirectory("PersonalAssistant");
                if (!Directory.Exists("PersonalAssistant/Meetings"))
                {
                    Directory.CreateDirectory("PersonalAssistant/Meetings");
                }
                if (!Directory.Exists("PersonalAssistant/Contacts"))
                {
                    Directory.CreateDirectory("PersonalAssistant/Contacts");
                }
            }
            else
            {
                if (!Directory.Exists("PersonalAssistant/Meetings"))
                {
                    Directory.CreateDirectory("PersonalAssistant/Meetings");
                }
                if (!Directory.Exists("PersonalAssistant/Contacts"))
                {
                    Directory.CreateDirectory("PersonalAssistant/Contacts");
                }
            }
            PersonalAssistant PA = new PersonalAssistant();
            PA.Welcome();
        }
    }
}